package com.sysolve.betterCity.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sysolve.betterCity.model.ActivityType;
import com.sysolve.betterCity.model.Place;
import com.sysolve.betterCity.service.BetterCityService;

/**
 * Servlet implementation class for Servlet: RetrieveActivityType
 *
 */
 public class RetrieveActivityType extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public RetrieveActivityType() {
		super();
	}   	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		BetterCityService service = BetterCityService.getInstance();
		List<ActivityType> list = service.listActivityType();
		
		response.setContentType("text/html");  
		response.setCharacterEncoding("utf-8");
		
        PrintWriter out = response.getWriter();
        
        out.println("选择活动类型 ");
      
        if (list!=null && !list.isEmpty()) {
        	for (ActivityType a:list) {
        		out.println("<span><input onclick=\"chooseActivity('"+a.getTitle()+"')\" type=\"radio\" name=\"activityType\" value=\""+a.getId()+"\">");
        		out.println("<img src=\""+a.getIcon()+"\" alt=\""+ a.getTitle() +"\">");
        		out.println("</span> ");
        	}
        }
        
        out.close();
	}  	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}   	  	    
}